﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.SessionState;
using Hjp.FrameWork.Common;
using Wjtour.BLL;

namespace Wjtour.Ajax
{
    /// <summary>
    /// Summary description for login
    /// </summary>
    public class down : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string path = context.Request["path"];
            string physicalPath = context.Server.MapPath(path);
            FileInfo file = new FileInfo(physicalPath);
            if (file.Exists)
            {
                context.Response.Clear();
                context.Response.AddHeader("Content-Length", file.Length.ToString());
                context.Response.Buffer = true;
                context.Response.Charset = "UTF8";
                context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + context.Server.UrlEncode(file.Name));
                context.Response.ContentEncoding = System.Text.Encoding.UTF8;
                context.Response.ContentType = "application/octet-stream";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}